package org.example.curriculum_design_6_16.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.curriculum_design_6_16.entity.pojo.IpScoringRule;
import org.example.curriculum_design_6_16.entity.vo.Result;
import org.example.curriculum_design_6_16.service.IpScoringRuleService;
import org.example.curriculum_design_6_16.mapper.IpScoringRuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 郑凯
 * @description 针对表【ip_scoring_rule(知识产权评分规则表)】的数据库操作Service实现
 * @createDate 2025-06-23 09:02:07
 */
@Service
public class IpScoringRuleServiceImpl extends ServiceImpl<IpScoringRuleMapper, IpScoringRule>
        implements IpScoringRuleService{
    @Autowired
    private IpScoringRuleMapper ipScoringRuleMapper;

    @Override
    public int addIpScoringRule(IpScoringRule ipScoringRule) {
        return ipScoringRuleMapper.insertIpScoringRule(ipScoringRule);
    }

    @Override
    public int updateIpScoringRule(IpScoringRule ipScoringRule) {
        return ipScoringRuleMapper.updateIpScoringRule(ipScoringRule);
    }

    @Override
    public int deleteIpScoringRule(Integer id) {
        return ipScoringRuleMapper.deleteIpScoringRuleById(id);
    }

    @Override
    public IpScoringRule getIpScoringRuleById(Integer id) {
        IpScoringRule rule = ipScoringRuleMapper.getIpScoringRuleById(id);
        if (rule == null) throw new RuntimeException("未找到ID为" + id + "的评分规则");
        return rule;
    }

    @Override
    public List<IpScoringRule> getAllIpScoringRules() {
        return ipScoringRuleMapper.getAllIpScoringRules();
    }
}